[SUBROUTINE]
version = 1.14
icon = tool-change.png
name = _("Thread Mill Change")
type = tmill_chng
help = _("<b>Change thread mill and/or settings</b>&#10;Changes setting accordingly even if disabled")
order = act h1 dnum h2 tlc spindle_dir cooling h4 feed v_feed speed h7 teeth lead_clearance cut_depth

[PARAM_ACT]
name = _("Active")
icon = enable.png
type = bool
value = 1
tool_tip = _("Params will be set even if disabled")

[PARAM_H1]
name = _("Select thread mill")
type = sub-header

[PARAM_H2]
name = _("Action")
type = sub-header

[PARAM_H4]
name = _("Feed and speed")
type = sub-header

[PARAM_DNUM]
name = _("Tool number")
header = h1
type = tool
icon = tool.png
tool_tip = _("Select from tool table")
value = 0

[PARAM_TLC]
name = _("Use length comp")
icon = comp-l.png
type = combo
options = _("No=0:Already mounted and touched=3:From tool table=1:Table and probe=2")
header = h2
value = 3
tool_tip = _("Use G43 and probe if setup")

[PARAM_COOLING]
name = _("Use cooling")
header = h2
type = combo
options = _("None=9:Flood=8:Mist=7")
icon = snowflake.png
tool_tip = _("Use flood, mist or none")
value = 8

[PARAM_SPEED]
name = _("Spindle speed")
header = h4
type = int
minimum_value = 100
icon = tool-spindle.png
tool_tip = _("Set spindle speed")
value = 1000

[PARAM_SPINDLE_DIR]
name = _("Start spindle")
header = h2
type = combo
options = _("No=0:Clockwise=3:Counter-clockwise=4")
icon = spindle-start.png
tool_tip = _("Select drill rotation")
value = 3

[PARAM_FEED]
name = _("Feed")
header = h4
type = float
icon = tool-feed.png
tool_tip = _("Feed at 100% engagement")
minimum_value = 0.0
not_allowed = 0
value = 10
metric_value = 250

[PARAM_V_FEED]
name = _("Vertical")
header = h4
type = float
icon = tool-vertical-feed.png
tool_tip = _("Plunge or drill feed")
value = 8
not_allowed = 0
metric_value = 200
minimum_value = 0.0

[PARAM_H7]
name = _("Params")
type = sub-header

[PARAM_CUT_DEPTH]
name = _("Cutter engagement")
type = float
minimum_value = 0.0
tool_tip = _("Depth of cutter engagment in machine units per pass")
value = 0.020
header = h7
metric_value = 0.5
not_allowed = 0
icon = thread-eng.png

[PARAM_CUT_TEETH]
name = _("Cutter teeth")
type = int
minimum_value = 1
tool_tip = _("Number of cutter teeth")
value = 1
header = h7
icon = cutter-teeth.png

[PARAM_LEAD_CLEARANCE]
name = _("Lead-in clearance")
type = float
tool_tip = _("Distance from face in machine units before engaging cutter")
value = 0.040
header = h7
metric_value = 1
not_allowed = 0
icon = lead-in-thread.png


[DEFINITIONS]
content =
;	<eval>self.include_once(file name here)</eval>

[CALL]
content =
	(begin #sub_name)
	(thread mill change params and changing code author : Fernand Veilleux)
	
	#<_spindle_dir>      =  #param_spindle_dir
	#<_cooling_mode>     =  #param_cooling
	
	#<_feed_normal>      =  #param_feed
	#<_rpm_normal>       =  #param_speed
	#<_feed_vertical>    =  #param_v_feed
	#<_tool_usage>       =  4
	#<_thread_cut_depth> =  #param_cut_depth
	#<_thread_cut_teeth> =  #param_cut_teeth
	#<_thread_lead_in>   =  #param_lead_clearance
	
	o<#self_id_tlc> if [[#param_tlc EQ 3] AND [#param_dnum GT 0]]
		M61 Q#param_dnum
	o<#self_id_tlc> endif
	
	o<#self_id_act> if [#param_act AND [#param_dnum NE #5400]]
		M9
		T#param_dnum M6
	o<#self_id_act> endif
	
	o<#self_id_lc> if [[#param_tlc EQ 1] OR [#param_tlc EQ 2]]
		G43 H#param_dnum
	o<#self_id_lc> endif
	
	o<#self_id_01> if [[#<_spindle_dir> GT 0] AND #<_spindle_all_time>]
		o<set_feed_rate_and_speed> CALL [1]
	o<#self_id_01> endif
	(end #sub_name)
